<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:p="http://primefaces.org/ui"
      xmlns:f="http://java.sun.com/jsf/core">
    
    <ui:composition>
        
        <p:dialog id="dialogRelatorios"
                  header="Relatórios"
                  widgetVar="dlgRelatorios"
                  modal="true"
                  appendToBody="true"
                  style="width: 300px">

            <h:form  >

                <p:fieldset legend="Relatório" >

                    <p:selectOneMenu value="#{relatorioBean.relatorio}"
                                     style="width: 100%;" 
                                     required="true"
                                     requiredMessage="Informe o relatório que deseja imprimir!"
                                     >

                        <f:selectItems value="#{relatorioBean.relatorios}" />

                        <p:ajax event="change" update="btnImprimir" />

                    </p:selectOneMenu>

                    <hr/>
                    <p:commandButton id="btnImprimir"
                                     value="Imprimir" 
                                     action="#{relatorioBean.imprimirRelatorio()}" 
                                     onclick="this.form.target = '_blank'"
                                     ajax="false" 
                                     disabled="#{relatorioBean.relatorio.nome.equals('Selecione')}" />

                </p:fieldset>

                <br/>

            </h:form>

        </p:dialog>
        
    </ui:composition>
    
</html>

